import { RechargeActiveItem } from "../loginNotice/OpenRecharge/RechargeActiveItem";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SConsumeYBRetRewardInfo } from "../../../../Message/Public/SConsumeYBRetRewardInfo";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { ItemData } from "../../resource/info/ItemData";
import { EffectManager } from "../../manager/EffectManager";
type int = number;
//class ConsumeEveryDayItem
    
    export  class ConsumeEveryDayItem extends RechargeActiveItem
    {
        constructor()
        {
            super();
            addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClickHandler);
            return;
        }

        /* internal  */onMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            dispatchEvent(new DataEvent(EventName.ConsumeYBRetRewardItemSelect, this.rewardInfo));
            return;
        }

        public /* override */ get itemCode(): int
        {
            var loc1=0;
            if (this._rewardInfo) 
            {
                loc1 = this._rewardInfo.code;
            }
            return loc1;
        }

        public /* override */ get value(): int
        {
            var loc1=0;
            if (this._rewardInfo) 
            {
                loc1 = this._rewardInfo.price;
            }
            return loc1;
        }

        public get rewardInfo(): SConsumeYBRetRewardInfo
        {
            return this._rewardInfo;
        }

        protected /* override */ onGetBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._rewardInfo) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ConsumeEverydayGetReward, this._rewardInfo.target));
            }
            return;
        }

        public updateName(arg1: string): void
        {
            _nameTxt.text = arg1;
            return;
        }

        public /* override */ updateData(arg1: int): void
        {
            return;
        }

        public updateRewardInfo(arg1: SConsumeYBRetRewardInfo): void
        {
            var loc1=null;
            this._rewardInfo = arg1;
            if (this._rewardInfo == null) 
            {
                return;
            }
            if (arg1.code > 0) 
            {
                loc1 = new ItemData(arg1.code);
                _baseItem.itemData = loc1;
                _nameTxt.text = loc1.itemInfo.item.name;
            }
            if (this._rewardInfo.canGet) 
            {
                _getBtn.enabled = true;
                EffectManager.glowFilterReg(_getBtn, [_glowYellow], 0.5, 6, 3, 20);
            }
            else 
            {
                _getBtn.enabled = false;
                EffectManager.glowFilterUnReg(_getBtn);
            }
            return;
        }

        public /* override */ moneyUpdate(): void
        {
            return;
        }

        /* internal */ /* var */_rewardInfo: SConsumeYBRetRewardInfo;
    }
